<template>
	<view class="tn-safe-area-inset-bottom pages-a">
		<tn-nav-bar fixed customBack :bottomShadow="false" backgroundColor="#FFFFFF">
			<view slot="back" class='tn-custom-nav-bar__back' @click="goBack">
				<text class='icon tn-icon-left'></text>
				<text class='icon tn-icon-home-capsule-fill'></text>
			</view>
			<view class="tn-flex tn-flex-col-center tn-flex-row-center ">
				<text class="tn-text-bold tn-text-xl tn-color-black">音频推荐</text>
			</view>
		</tn-nav-bar>

		<!-- 音频推荐开始 -->
		<view class="tn-margin-bottom-xl" :style="{paddingTop: vuex_custom_bar_height + 'px', width: '100%'}">
			<swiper class="card-swiper" :circular="true" :autoplay="true" duration="500" interval="8000" @change="cardSwiper" indicator-active-color="#FFF" indicator-dots="true">
				<swiper-item v-for="(item,index) in topTagList" :key="index" :class="cardCur==index ? 'cur':''"
					@click="navigatorAudioListPage(item)">
					<view class="swiper-item image-banner"
						:style="'background-image:url('+ item.cover + ');background-size: cover;border-radius: 15rpx;'">
					</view>
					<view class="swiper-item-text">
						<view class="tn-text-bold tn-color-white" style="font-size: 50rpx;">{{item.title || ""}}</view>
						<view class="tn-text-sm tn-text-bold tn-color-white tn-padding-top-sm tn-padding-bottom-sm">
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 音频推荐结束 -->
		
		<!-- 音频列表 -->
		<view class="">
			<view class='nav-list'>
				<block v-for="(item, index) in publicTagList" :key="index">
					<navigator @click="navigatorAudioListPage(item)" :style="{backgroundImage:'url('+item.cover+')'}" hover-class='none'
						class="nav-list-item tn-shadow-blur tn-cool-bg-image">
						<view class="nav-link">
							<view class='title'>{{ item.title }}</view>
							<!-- <view class='author'> <text class="tn-icon-code tn-padding-right-xs"></text> {{ content_item.author }}
							</view> -->
						</view>
					</navigator>
				</block>
			</view>
		</view>
		<!-- 音频列表结束 -->
		
	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	import { tagList } from "@/utils/api/audio.js"
	export default {
		name: 'TemplateNavigation',
		mixins: [template_page_mixin],
		data() {
			return {
				publicTagList: [],
				topTagList: [],
				cardCur: 0,
			}
		},
		onLoad() {
			this.audioTagList(1)
			this.audioTagList(2)
		},
		methods: {
			audioTagList(isTop = 1) {
				tagList({ is_top: isTop }).then(res => {
					if (isTop === 1) {
						this.topTagList = res.data
					} else {
						this.publicTagList = res.data
					}
				})
			},
			cardSwiper(e) {
				this.cardCur = e.detail.current
			},
			navigatorAudioListPage(item) {
				uni.navigateTo({
					url: "/pageAudio/list/index?cate_uid=" + item.uid
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	/* 组件导航列表 start*/
	.nav-list {
		display: flex;
		flex-wrap: wrap;
		padding: 0rpx 12rpx 0rpx;
		justify-content: space-between;

		/* 列表元素 start */
		.nav-list-item {
			padding: 0rpx 10rpx 15rpx 10rpx;
			border-radius: 12rpx;
			width: 45%;
			height: 160rpx;
			margin: 0 18rpx 30rpx;
			background-size: cover;
			background-position: center;
			position: relative;
			z-index: 99;

			/* 元素标题 start */
			.nav-link {
				font-size: 32rpx;
				text-transform: capitalize;
				padding: 0 0 10rpx 0;
				position: relative;

				.title {
					font-weight: bold;
					font-size: 36rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 160rpx;
				}

				.author {
					font-size: 25rpx;
					color: #FFFFFF;
					margin-top: 10rpx;
					margin-left: -10rpx;
					text-align: center;
				}
			}

			/* 元素标题 end */

			/* 元素图标 start */
			.icon {
				font-variant: small-caps;
				position: absolute;
				top: 20rpx;
				right: 50rpx;
				left: 37%;
				width: 90rpx;
				height: 90rpx;
				line-height: 90rpx;
				margin: 0;
				padding: 0;
				display: inline-flex;
				text-align: center;
				justify-content: center;
				vertical-align: middle;
				font-size: 50rpx;
				color: #FFFFFF;
				white-space: nowrap;
				opacity: 0.9;
				background-color: rgba(0, 0, 0, 0.05);
				background-size: cover;
				background-position: 50%;
				border-radius: 5000rpx;
			}

			/* 元素图标 end */
		}

		/* 列表元素 end */
	}

	.pages-a {
		max-height: 100vh;
		width: 100%;
	}
	
/* 轮播视觉差 start */
	.card-swiper {
		height: 330rpx !important;
	}

	.card-swiper swiper-item {
		width: 750rpx !important;
		left: 0rpx;
		box-sizing: border-box;
		padding: 30rpx 30rpx 0rpx 30rpx;
		overflow: initial;
	}

	.card-swiper swiper-item .swiper-item {
		width: 100%;
		display: block;
		height: 100%;
		border-radius: 15rpx;
		transform: scale(1);
		transition: all 0.2s ease-in 0s;
		will-change: transform;
		// overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item {
		transform: none;
		transition: all 0.2s ease-in 0s;
		will-change: transform;
	}

	.card-swiper swiper-item .swiper-item-text {
		margin-top: -220rpx;
		text-align: center;
		width: 100%;
		display: block;
		border-radius: 10rpx;
		transform: translate(100rpx, 0rpx) scale(0.9, 0.9);
		transition: all 0.6s ease 0s;
		will-change: transform;
		overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item-text {
		margin-top: -220rpx;
		width: 100%;
		transform: translate(0rpx, 0rpx) scale(0.9, 0.9);
		transition: all 0.6s ease 0s;
		will-change: transform;
	}

	.image-banner {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.image-banner image {
		width: 100%;
		height: 100%;
	}
</style>